﻿using System.Collections.Generic;
using System.Linq;
using DataBaseLayer.Dto;

namespace DataBaseLayer.Extensions
{
	public static class GalleryEx
	{
		public static GalleryData ToDTO(this Gallery entity)
		{
			if (entity == null) return null;

			var dto = new GalleryData
			{
				Name = entity.Name,
				GalleryId = entity.GalleryId,
				Images = entity.Images.ToDTOs(),
				IsFotoclub = entity.IsFotoclub,
				IsImagesGallery = entity.IsImagesGallery
			};

			return dto;
		}

		public static List<GalleryData> ToDTOs(this IEnumerable<Gallery> entities)
		{
			if (entities == null) return null;

			return entities.Select(e => e.ToDTO()).ToList();
		}
	}
}
